﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Database;

namespace Business
{
    public class QuanLyTaiKhoan
    {

        TrungTamEntities trungtam = new TrungTamEntities();
        public QuanLyTaiKhoan()
        {
        }
        public NhanVien laythongtinnguoidung(string taikhoan)
        {
            var nguoidung = from p in trungtam.NguoiDungs
                            where p.TaiKhoan.Equals(taikhoan)
                            select p.NhanVien;
            return nguoidung.First();
        }
        public bool kiemtranguoidung(string taikhoan,string matkhau)
        {
            
            try
            {
                var nguoidung = from p in trungtam.NguoiDungs
                                where p.TaiKhoan.Equals(taikhoan)
                                   && p.MatKhau.Equals(matkhau)                                  
                                select p;
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        
        public void thaydoimatkhau(string taikhoan,string matkhaumoi)
        {
            var nguoidung = from p in trungtam.NguoiDungs
                            where p.TaiKhoan.Equals(taikhoan)
                            select p;
            nguoidung.First().MatKhau = matkhaumoi;
            trungtam.SaveChanges();
        }
    }
}
